home *** CD-ROM | disk | FTP | other *** search
-
- /*
-
- NAME
- CenterWindow - center a DLOG, ALRT,
- or WIND resource
-
- DESCRIPTION
- Reads resource into memory and modifies
- bounds rect so it is somewhat centered
- on the screen.
-
-
- INPUT PARAMETERS
- Type...............................ResType
- Resource Type 'DLOG', 'ALRT', or 'WIND'.
-
- ID...................................short
- Resource number for DLOG, ALRT, or WIND.
-
-
- OUTPUT PARAMETERS
- none
-
-
- HISTORY
- Dana - Jun 21, 1988 9:33 AM (new)
- Linda - July 10, 1989
-
-
- COPYRIGHT © 1989 Silicon Beach Software, Inc.
- Permission is hereby granted to the purchaser
- to use this source code for the limited
- purpose of producing and distributing compiled
- object files and applications. The source
- code is and shall remain the sole property of
- Silicon Beach Software, Inc., and except as
- expressly provided, purchaser obtains no
- right, title or interest in the source code.
- Distribution of the un-compiled or text
- versions of this source code is prohibited.
-
- */
-
- #define MBarHeight ( *(short *)0xBAA )
- #define nil 0
-
- CenterWindow( Type, ID )
-
- ResType Type;
- short ID;
-
- {
-
- DialogTHndl windowHdl;
- Rect boundsRect;
- short screenHeight;
- short screenWidth;
- short boxHeight;
- short boxWidth;
- short topMargin;
- short leftMargin;
- GrafPtr tempPort, savePort;
-
- windowHdl = (DialogTHndl)GetResource( Type, ID );
-
- if( windowHdl != nil ) {
- /* open a temporary port to */
- /* get the size of the screen */
- GetPort( &savePort );
- tempPort = (GrafPtr)NewPtr( sizeof( GrafPort ) );
- OpenPort( tempPort );
- screenWidth = tempPort->portRect.right -
- tempPort->portRect.left;
- screenHeight = tempPort->portRect.bottom -
- tempPort->portRect.top - MBarHeight;
- ClosePort( tempPort );
- DisposPtr( (Ptr)tempPort );
- SetPort( savePort );
-
- /* get size of dialog window */
- boundsRect = (*windowHdl)->boundsRect;
- boxHeight = boundsRect.bottom - boundsRect.top;
- boxWidth = boundsRect.right - boundsRect.left;
-
- /* compute position for the dialog */
- topMargin = (screenHeight-boxHeight)/4;
- leftMargin = (screenWidth-boxWidth)/2;
-
- boundsRect.top = MBarHeight + topMargin;
- boundsRect.left = leftMargin;
- boundsRect.bottom = boundsRect.top + boxHeight;
- boundsRect.right = boundsRect.left + boxWidth;
-
- (*windowHdl)->boundsRect = boundsRect;
-
- }/* if( got the resource ) */
- }/*CenterWindow*/
-
-